#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "InteractionFragment.h"
#include "InteractionOperatorKind.h"
#include "NamedElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Gate;
class InteractionOperand;

/// <summary>
/// CombinedFragment
/// A CombinedFragment defines an expression of InteractionFragments. A
/// CombinedFragment is defined by an interaction operator and corresponding
/// InteractionOperands. Through the use of CombinedFragments the user will be able
/// to describe a number of traces in a compact and concise manner.
/// </summary>
class UMLMODEL_EXPORT CombinedFragment : public NamedElement, public InteractionFragment {

public: // Constructors and destructors
    explicit CombinedFragment(const QString& umlType="uml::CombinedFragment");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// cfragmentGates getter
    /// Specifies the gates that form the interface between this CombinedFragment and
    /// its surroundings
    /// </summary>
    vector<shared_ptr<Gate>>& cfragmentGates();

    /// <summary>
    /// interactionOperator getter
    /// Specifies the operation which defines the semantics of this combination of
    /// InteractionFragments.
    /// </summary>
    InteractionOperatorKind interactionOperator() const;

    /// <summary>
    /// interactionOperator setter
    /// Specifies the operation which defines the semantics of this combination of
    /// InteractionFragments.
    /// </summary>
    void setInteractionOperator(InteractionOperatorKind value);

    /// <summary>
    /// operands getter
    /// The set of operands of the combined fragment.
    /// </summary>
    vector<shared_ptr<InteractionOperand>>& operands();

private: // Fields
    /// <summary>
    /// cfragmentGates
    /// Specifies the gates that form the interface between this CombinedFragment and
    /// its surroundings
    /// </summary>
    vector<shared_ptr<Gate>> cfragmentGates_;

    /// <summary>
    /// interactionOperator
    /// Specifies the operation which defines the semantics of this combination of
    /// InteractionFragments.
    /// </summary>
    InteractionOperatorKind interactionOperator_ = InteractionOperatorKind::kseq;

    /// <summary>
    /// operands
    /// The set of operands of the combined fragment.
    /// </summary>
    vector<shared_ptr<InteractionOperand>> operands_;

};

} // namespace uml
